import mongoose from "mongoose";
import uniqueValidator from "mongoose-unique-validator";

const userScheme = new mongoose.Schema(
  {
    fullName: {
      type: String,
      required: true,
    },
    username: {
      type: String,
      required: true,
      unique: true,
    },
    password: {
      type: String,
      required: true,
      minlength: 6,
    },
    gender: {
      type: String,
      required: true,
      enum: ["male", "female"],
    },
    profilePic: {
      type: String,
      default: "",
    },
  },
  { timestamps: true },
);

userScheme.plugin(uniqueValidator, { message: "is already taken" });
const User = mongoose.models.User || mongoose.model("User", userScheme);

export default User;
